<template>
  <div class="data_detail">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="数据详情" name="detail">
        <div class="select" style="display: inline-flex;">
          <el-form :inline="true" :model="form" class="demo-form-inline">
            <el-form-item label="年月：">
              <el-date-picker size="small"
                              v-model="form.salaryYearMonth"
                              @change="handleCurrentChange(1)"
                              type="month"
                              placeholder="选择月"
                              :clearable="false">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="部门：">
              <el-select v-model="form.depts" multiple placeholder="请选择部门..." @change="deptChange" size="small"
                         :collapse-tags="true"
                         filterable clearable>
                <el-option :label="item.deptLevel2" :value="item.deptLevel2" v-for="item in deptList">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="组别：">
              <el-select v-model="form.groupNames" multiple placeholder="请选择组别..." size="small"
                         :collapse-tags="true"
                         filterable clearable>
                <el-option :label="item.groupName" :value="item.groupName" v-for="item in groupList">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="姓名：">
              <el-select v-model="form.userNames" placeholder="请选择员工姓名..." size="small" value-key="id" multiple
                         :collapse-tags="true" style="width: 20vw;"
                         filterable clearable>
                <el-option :label="item.userName+'（'+item.jobNo+'）'" :value="item.userName"
                           v-for="item in $store.state.userList">
                  <span style="float: left">{{ item.userName }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.jobNo }}</span>
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="small" @click="handleCurrentChange(1)">筛选</el-button>
              <el-button type="primary" size="small" @click="dialogFormVisible=true">重新计算数据</el-button>
              <el-button type="primary" size="small" @click="exportData(false)">导出本页</el-button>
              <el-button type="primary" size="small" @click="exportData(true)">导出全部</el-button>
            </el-form-item>
          </el-form>
        </div>
        <el-table
            :data="tableData1"
            stripe
            border
            id="table-detail"
            @selection-change="handleSelectionChange"
            default-expand-all
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center'}">
          <!--          <el-table-column>-->
          <!--            <template slot="header">四川瀚海{{ form.salaryYearMonth|formatDateMonth }}工资明细表（财务表）</template>-->
          <el-table-column label="薪资年月" prop="salaryYearMonth" min-width="120" fixed>
            <template slot-scope="scope">
              {{ scope.row.salaryYearMonth|formatDateMonth }}
            </template>
          </el-table-column>
          <el-table-column label="工号" prop="jobNo" fixed="left"></el-table-column>
          <el-table-column label="姓名" prop="username" fixed="left"></el-table-column>
          <el-table-column label="证件号码" prop="cid" :show-overflow-tooltip="true" min-width="180px"></el-table-column>
          <el-table-column label="部门" prop="dept" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="职位" prop="position" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="薪资属性" prop="salaryType" width="100px"></el-table-column>
          <el-table-column label="人力性质" prop="resourcesType" width="100px"></el-table-column>
          <el-table-column label="夜班天数" prop="nightShiftDays" width="100px"></el-table-column>
          <el-table-column label="夜班补贴" prop="nightShiftAllowance" width="100px"></el-table-column>
          <el-table-column label="误餐补贴" prop="mealAllowance" width="100px"></el-table-column>
          <el-table-column label="绩效奖" prop="achievementBonus" width="100px"></el-table-column>
          <el-table-column label="标准工资" prop="standardWage" width="100px"></el-table-column>
          <el-table-column label="总工时" prop="totalAttendanceHours" width="100px"></el-table-column>
          <el-table-column label="应出勤" prop="planJobDays" width="100px"></el-table-column>
          <el-table-column label="实际出勤" prop="actualJobDays" width="100px"></el-table-column>
          <el-table-column label="工作日出勤" prop="basicWageCalculateDays" :min-width="160"></el-table-column>
          <el-table-column label="周末出勤天数" prop="weekendJobDays" :min-width="120"></el-table-column>
          <el-table-column label="基本出勤工资" prop="basicAttendanceWage" :min-width="120"></el-table-column>
          <el-table-column label="在职补贴" prop="timeOnJobSubsidy" width="100px">
          </el-table-column>
          <el-table-column label="平时加班小时" prop="normalOvertimeHours" :min-width="120"></el-table-column>
          <el-table-column label="平时加班工资" prop="normalOvertimeWage" :min-width="120"></el-table-column>
          <el-table-column label="周末加班小时" prop="weekendOvertimeHours" :min-width="120"></el-table-column>
          <el-table-column label="周末加班工资" prop="weekendOvertimeWage" :min-width="120"></el-table-column>
          <el-table-column label="法定加班小时" prop="legalOvertimeHours" :min-width="120"></el-table-column>
          <el-table-column label="法定加班工资" prop="legalOvertimeWage" :min-width="120"></el-table-column>
          <el-table-column label="病假天数" prop="sickLeaveDays" width="100px"></el-table-column>
          <el-table-column label="病假工资合计" prop="totalSickPay" :min-width="120"></el-table-column>
          <el-table-column label="工龄奖" prop="seniorityAward"></el-table-column>
          <el-table-column label="孝工奖" prop="filialPietyAward"></el-table-column>
          <el-table-column label="效益奖金" prop="benefitBonus" width="100px"></el-table-column>
          <el-table-column label="岗位补贴" prop="postSubsidy" width="100px"></el-table-column>
          <el-table-column label="介绍奖" prop="introductionAward"></el-table-column>
          <el-table-column label="亲属补贴" prop="familyAllowance" width="100px"></el-table-column>
          <el-table-column label="子女补贴" prop="childAllowance" width="100px"></el-table-column>
          <el-table-column label="高温补贴" prop="highTemperatureAllowance" width="100px"></el-table-column>
          <el-table-column label="全勤奖" prop="fullAttendanceBonus"></el-table-column>

          <el-table-column label="固定工资合计" prop="totalFixedSalary" :min-width="120"></el-table-column>
          <el-table-column label="员工大会" prop="staffMeeting" width="100px"></el-table-column>
          <el-table-column label="项目奖金" prop="projectBonus" width="100px"></el-table-column>
          <el-table-column label="补前期工资差异" prop="beforeWages" :min-width="150"></el-table-column>
          <el-table-column label="其他奖励" prop="otherRewards" width="100px"></el-table-column>
          <el-table-column label="其他工资合计" prop="totalOtherWages" :min-width="120"></el-table-column>
          <el-table-column label="绩效考核" prop="kpi" width="100px"></el-table-column>
          <el-table-column label="水电气" prop="waterAndElectricity"></el-table-column>
          <el-table-column label="其他扣款" prop="otherDeductions" width="100px"></el-table-column>
          <el-table-column label="扣款小计" prop="subtotalDeduction" width="100px"></el-table-column>
          <el-table-column label="应发工资" prop="wagesPayable" width="100px"></el-table-column>
          <el-table-column label="个人养老" prop="individualPension" width="100px"></el-table-column>
          <el-table-column label="个人医疗" prop="personalMedicalTreatment" width="100px"></el-table-column>
          <el-table-column label="个人失业" prop="individualUnemployment" width="100px"></el-table-column>
          <el-table-column label="社保合计" prop="totalSocialSecurity" width="100px"></el-table-column>
          <el-table-column label="应纳税所得额" prop="taxableIncome" :min-width="120"></el-table-column>
          <el-table-column label="个税" prop="personalIncomeTax"></el-table-column>
          <el-table-column label="前期已发工资" prop="beforeSalaryPay" :min-width="120"></el-table-column>
          <el-table-column label="本期实发工资" prop="actualSalaryPay" :min-width="120"></el-table-column>
          <el-table-column label="计算时间" prop="createTime" :min-width="150" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              {{ scope.row.createTime|formatDate }}
            </template>
          </el-table-column>


          <el-table-column label="招聘渠道" prop="recruitmentChannels" width="100px"></el-table-column>
          <!--          </el-table-column>-->

        </el-table>
        <div class="block">
          <el-pagination
              hide-on-single-page
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[size, size*2, size*3, size*4 ,total]"
              :page-size=size
              layout="total, sizes, prev, pager, next, jumper"
              :total=total>
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="数据汇总" name="summary">
        <div class="select" style="display: inline-flex;">
          <el-form :inline="true" :model="form" class="demo-form-inline">
            <el-form-item label="年月">
              <el-date-picker
                  v-model="form.salaryYearMonth"
                  @change="getDataList"
                  size="small"
                  type="month"
                  placeholder="选择月">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="small" @click="getDataList">筛选</el-button>
              <el-button type="primary" size="small" @click="dialogFormVisible=true">重新计算数据</el-button>
            </el-form-item>

          </el-form>
        </div>
        <el-table
            :data="tableData.filter(data=>data.channel.includes('自招'))"
            stripe
            border
            :show-summary="true"
            @selection-change="handleSelectionChange"
            default-expand-all
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center'}">
          <el-table-column>
            <template slot="header">四川瀚海{{ form.salaryYearMonth|formatDateMonth }}工资统计表（财务表）</template>
            <el-table-column label="应聘渠道" prop="channel">
            </el-table-column>
            <el-table-column label="部门" prop="dept" sortable min-width="120">
            </el-table-column>
            <el-table-column label="人数" prop="peopleNum">
            </el-table-column>
            <el-table-column label="应付项">
              <el-table-column label="应付总额" prop="shouldPayAll">
              </el-table-column>
              <el-table-column label="责任制应付" prop="shouldPayResponsibility">
              </el-table-column>
              <el-table-column label="计时制应付" prop="shouldPayResponsibility">
              </el-table-column>
            </el-table-column>
            <el-table-column label="扣款项">
              <el-table-column label="个人社保" prop="socialSecurity">
              </el-table-column>
              <el-table-column label="个税" prop="incomeTax">
              </el-table-column>
              <el-table-column label="水电气" prop="waterElectricity">
              </el-table-column>
              <el-table-column label="其他" prop="otherDeductions">
              </el-table-column>
            </el-table-column>
            <el-table-column label="前期已发">
              <el-table-column label="子女补助" prop="childAllowance">
              </el-table-column>
            </el-table-column>
            <el-table-column label="本次实发项">
              <el-table-column label="实发总额" prop="actualPayAll">
              </el-table-column>
              <el-table-column label="责任制" prop="actualPayResponsibility">
              </el-table-column>
              <el-table-column label="计时制" prop="actualPayTiming">
              </el-table-column>
            </el-table-column>
          </el-table-column>
        </el-table>
        <el-table
            :data="tableData.filter(data=>!data.channel.includes('自招'))"
            stripe
            :show-header="false"
            border
            :show-summary="true"
            @selection-change="handleSelectionChange"
            default-expand-all
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center'}">
          <el-table-column>
            <template slot="header">四川瀚海{{ form.salaryYearMonth|formatDateMonth }}工资统计表（财务表）</template>
            <el-table-column label="应聘渠道" prop="channel">
            </el-table-column>
            <el-table-column label="部门" prop="dept" sortable min-width="120">
            </el-table-column>
            <el-table-column label="人数" prop="peopleNum">
            </el-table-column>
            <el-table-column label="应付项">
              <el-table-column label="应付总额" prop="shouldPayAll">
              </el-table-column>
              <el-table-column label="责任制应付" prop="shouldPayResponsibility">
              </el-table-column>
              <el-table-column label="计时制应付" prop="shouldPayResponsibility">
              </el-table-column>
            </el-table-column>
            <el-table-column label="扣款项">
              <el-table-column label="个人社保" prop="socialSecurity">
              </el-table-column>
              <el-table-column label="个税" prop="incomeTax">
              </el-table-column>
              <el-table-column label="水电气" prop="waterElectricity">
              </el-table-column>
              <el-table-column label="其他" prop="otherDeductions">
              </el-table-column>
            </el-table-column>
            <el-table-column label="前期已发">
              <el-table-column label="子女补助" prop="childAllowance">
              </el-table-column>
            </el-table-column>
            <el-table-column label="本次实发项">
              <el-table-column label="实发总额" prop="actualPayAll">
              </el-table-column>
              <el-table-column label="责任制" prop="actualPayResponsibility">
              </el-table-column>
              <el-table-column label="计时制" prop="actualPayTiming">
              </el-table-column>
            </el-table-column>
          </el-table-column>

        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按年份数据查看" name="year">
        <el-form :inline="true">
          <el-form-item label="薪资年份">
            <el-date-picker
                v-model="year"
                type="year" size="small"
                placeholder="选择年" @change="getDataList">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input v-model="form.username" clearable @change="getDataList" size="small"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="getDataList" type="primary" size="small">筛选</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData2" border :header-cell-style="{'text-align':'center'}"
                  :cell-style="{'text-align':'center'}">
          <el-table-column label="姓名" prop="username"></el-table-column>
          <el-table-column label="工号" prop="jobNo"></el-table-column>
          <el-table-column label="部门" prop="dept"></el-table-column>
          <el-table-column label="职位" prop="position" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.1'" prop="january"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.2'" prop="february"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.3'" prop="march"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.4'" prop="april"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.5'" prop="may"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.6'" prop="june"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.7'" prop="july"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.8'" prop="august"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.9'" prop="september"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.10'" prop="october"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.11'" prop="november"></el-table-column>
          <el-table-column :label="year.getFullYear()+'.12'" prop="december"></el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
              hide-on-single-page
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[size, size*2, size*3, size*4 ,total]"
              :page-size=size
              layout="total, sizes, prev, pager, next, jumper"
              :total=total>
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-dialog :title="activeName==='summary'?'汇总数据计算':'详细数据计算'" :visible.sync="dialogFormVisible" center
               :before-close="handleClose">
      <el-form :model="form" label-width="80px">
        <el-form-item label="员工姓名">
          <el-select v-model="form.userIds" placeholder="请选择员工姓名..." multiple :collapse-tags="true"
                     style="width: 100%" value-key="id"
                     filterable clearable>
            <el-option :label="item.userName+'（'+item.jobNo+'）'" :value="item.userId"
                       v-for="item in $store.state.userList">
              <span style="float: left">{{ item.userName }}</span>
              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.jobNo }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="薪资年月">
          <el-date-picker style="width: 100%"
                          v-model="form.salaryYearMonth"
                          type="month"
                          placeholder="选择月">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-checkbox v-model="form.checked">拉取考勤数据</el-checkbox>
          <el-checkbox v-model="form.calculateAttendance">计算考勤数据</el-checkbox>
        </el-form-item>
        <el-form-item>
          <el-progress  :text-inside="true" :stroke-width="26" :percentage="progress.LQKQJG_VALUE" :format="formatLqkqjg"
                       :status="progress.lqkqjgStatus" v-if="form.checked&&progress.LQKQJG_VALUE"></el-progress>
          <el-progress :text-inside="true" :stroke-width="26" :percentage="progress.MRKQJS_VALUE" :format="formatMrkqjs"
                       :status="progress.mrkqjsStatus" v-if="form.calculateAttendance&&progress.MRKQJS_VALUE"
                       style="margin-top: 5px"></el-progress>
          <el-progress :text-inside="true" :stroke-width="26" :percentage="progress.MYKQJS_VALUE" :format="formatMykqjs"
                       :status="progress.mykqjsStatus" v-if="form.calculateAttendance&&progress.MYKQJS_VALUE"
                       style="margin-top: 5px"></el-progress>
          <el-progress :text-inside="true" :stroke-width="26" :percentage="progress.MYGZJS_VALUE" :format="formatMygzjs"
                       :status="progress.mygzjsStatus" v-if="progress.MYGZJS_VALUE"
                       style="margin-top: 5px"></el-progress>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="getDataSummary">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import ToolBar from "@/components/common/ToolBar";
import moment from "moment/moment";

export default {
  name: "DataDetail",
  components: {ToolBar},
  data() {
    return {
      // 轮询定时器
      progressInterval: null,
      progressKey: '',
      progress: {
        lqkqjgStatus: 'success',
        mrkqjsStatus: 'success',
        mykqjsStatus: 'success',
        mygzjsStatus: 'success'
      },
      activeName: 'detail',
      dingUsersList: [],
      form: {
        calculateAttendance:false,
        salaryYearMonth: moment(moment().subtract(1, "months").startOf('month')).format("YYYY-MM-DD"),
        checked: false
      },
      allNum: 0,
      successNum: 0,
      errorNum: 0,
      currentPage: 1,
      total: 0,
      size: 10,
      tableData: [],
      tableData1: [],
      tableData2: [],
      dialogFormVisible: false,
      year: new Date(),
      pages: 0,
      groupList: [],
      deptList: []
    };
  },
  created() {
    this.activeName = this.$store.state.dataDetailActiveName || 'detail'
    this.getDataList()
  },
  mounted() {
    this.getDeptList()
  },
  methods: {
    getDeptList() {
      axios.get("/fin_user_roster/deptList").then(res => {
        if (res.data.success) {
          this.deptList = res.data.data
        } else {
          this.deptList = []
        }
      })
    },
    handleClose(done) {
      if (!this.progress.FINISH) {
        done();
        return
      }
      this.$confirm('任务还没有完成，是否确认关闭？')
          .then(_ => {
            this.stopProgressInterval();
            done();
          })
          .catch(_ => {
          });
    },
    deptChange() {
      if (this.form.depts.length > 0) {
        this.getGroupList()
      }
    },
    getGroupList() {
      let data = {
        depts: this.form.depts
      }
      axios.post("/fin_user_roster/groupList", data).then(res => {
        if (res.data.success) {
          this.groupList = res.data.data
        } else {
          this.groupList = []
        }
      })
    },
    handleClick(tab, event) {
      console.log(tab, event);
      console.log(this.activeName)
      this.$store.commit("setDataDetailActiveName", this.activeName)
      this.getDataList()
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleEdit(row) {
      console.log(row);
      this.form = row
      this.setDialogVisible(false)
    },
    handleDelete(index, row) {
      console.log(index, row);
      this.$tools.showMessageBox("确认删除" + row.paramName + "(" + row.paramValue + ")？", "操作确认", 'warning').then(confirm => {
        axios.delete("/fin_family_allowance/delete/" + row.id).then(res => {
          if (res.data.success) {
            this.$tools.showMessage("参数" + row.paramName + "(" + row.paramValue + ")删除成功！", "success")
            this.getDataList()
          }
        })

      }).catch(cancel => {
        this.$tools.showMessage("操作已取消！", "info")
      })
    },
    getDataList() {
      this.dialogFormVisible = false
      console.log("查询数据：", this.form)
      switch (this.activeName) {
        case "summary":
          axios.post("/fin_wages_summary/list", this.form).then(res => {
            console.log("打卡信息：", res)
            if (res.data.success) {
              this.tableData = res.data.data
            } else {
              this.tableData = []
              this.total = 0
              this.pages = 1

            }
          })
          break;
        case "detail":
          axios.post("/fin_wages_detail/list/" + this.currentPage + "/" + this.size, this.form).then(res => {
            console.log("详细：", res)
            if (res.data.success) {
              this.tableData1 = res.data.data.records
              this.total = res.data.data.total
              this.pages = res.data.data.pages

            } else {
              this.tableData1 = []
              this.total = 0
              this.pages = 1

            }

          })
          break;
        case "year":
          this.form.year = this.year
          this.form.pageNumber = this.currentPage
          this.form.pageSize = this.size
          axios.post("/fin_wages_detail_vto/list", this.form).then(res => {
            console.log("查询结果：", res)
            if (res.data.success) {
              this.tableData2 = res.data.data.records
              this.total = res.data.data.total
              this.pages = res.data.data.pages
            } else {
              this.tableData2 = []
              this.total = 0
              this.pages = 1

            }
          })
      }
    },

    // 拉取考勤结果
    formatLqkqjg(percentage) {
      return percentage === 100 ? `拉取考勤结果成功，共耗时：${this.progress.LQKQJG_TIME}秒` : `拉取考勤结果：${percentage}%`;
    },

    // 每月考勤计算
    formatMykqjs(percentage) {
      return percentage === 100 ? `每月考勤计算成功，共耗时：${this.progress.MYKQJS_TIME}秒` : `每月考勤计算：${percentage}%`;
    },
    // 每日考勤计算
    formatMrkqjs(percentage) {
      return percentage === 100 ? `每日考勤计算成功，共耗时：${this.progress.MRKQJS_TIME}秒` : `每日考勤计算：${percentage}%`;
    },
    // 每月工资计算
    formatMygzjs(percentage) {
      return percentage === 100 ? `每月工资计算成功，共耗时：${this.progress.MYGZJS_TIME}秒` : `每月工资计算：${percentage}%`;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.size = val
      this.getDataList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val
      this.getDataList()
    },
    stopProgressInterval() {
      clearInterval(this.progressInterval);
      this.progressInterval = null;
      this.dialogFormVisible=false
    },
    getProgress() {
      axios.get("/fin_wages_detail/" + this.progressKey + "/progress").then(res => {
        if (res.status === 200) {
          if (!res.data) {
            this.stopProgressInterval();
            return
          }
          if (this.progress.FINISH==1) {
            this.stopProgressInterval();
            let time=this.form.calculateAttendance?(this.progress.MRKQJS_TIME+this.progress.MYKQJS_TIME):0;
            time+=this.progress.MYGZJS_TIME
            this.$tools.showNotification("计算完毕，共耗时："+time.toFixed(2)+"秒","通知","success")
            this.getDataList()
            return;
          }
          this.progress = res.data;
          if (this.progress.hasOwnProperty('LQKQJG_CODE') && this.progress.LQKQJG_CODE == 0) {
            this.progress.lqkqjgStatus = 'exception';
            this.stopProgressInterval();
          }
          if (this.progress.hasOwnProperty('MRKQJS_CODE') && this.progress.MRKQJS_CODE == 0) {
            this.progress.mrkqjsStatus = 'exception';
            this.stopProgressInterval();
          }
          if (this.progress.hasOwnProperty('MYKQJS_CODE') && this.progress.MYKQJS_CODE == 0) {
            this.progress.mykqjsStatus = 'exception';
            this.stopProgressInterval();
          }
          if (this.progress.hasOwnProperty('MYGZJS_CODE') && this.progress.MYGZJS_CODE == 0) {
            this.progress.mygzjsStatus = 'exception';
            this.stopProgressInterval();
          }
        }
      })
    },
    getDataSummary() {
      console.log("数据查询：", this.form)
      switch (this.activeName) {
        case "summary":
          console.log("计算汇总")
          axios.post("/fin_wages_summary/get", this.form).then(res => {
            if (res.data.success) {
              this.getDataList();
            }
          })
          break;
        case "detail":
          console.log("计算详细")
          axios.post("/fin_wages_detail/get", this.form).then(res => {
            if (res.status == 200) {
              this.progress = {};
              this.progressKey = res.data;
              // 实现轮询
              this.progressInterval = setInterval(() => {
                this.getProgress();
              }, 1000);
            }
          })
          break;
      }
    },
   async exportData(all) {
     // await this.$tools.showMessageBox("是否过滤导出？","操作选项","warning","过滤","不过滤").then(confirm=>{
     //    this.form.checked=true
     //  }).catch(cancel=>{
     //    this.form.checked=false
     //  })
      if (!all) {
        // 导出当前页
        this.form.page = this.currentPage;
        this.form.limit = this.size;
      } else {
        this.form.page = null;
        this.form.limit = null;
      }
      axios({
        method: 'post',
        url: '/excel/dataDetail', // 后端接口地址
        responseType: 'blob', // 表明返回数据是二进制文件
        data: this.form
      }).then(response => {
        let filename = '四川瀚海' + moment(this.form.salaryYearMonth).format('YYYY年MM月') + '工资明细表（财务表）.xlsx';
        fdCommon.down(filename, response.data)
        this.form.checked=false
      }).catch(error => {
        console.error('导出 Excel 失败:', error);
      });
    }

  },
  destroyed() {
    this.progressInterval = null;
  }
}
</script>

<style scoped>
</style>
